/// Copyright (c) Microsoft Corporation.  All rights reserved.

using System;
using System.Collections;
using System.Text;
using System.ComponentModel;
using System.Windows.Forms;
using NUnit.Framework;
using NUnit.Extensions.Forms;
using System.Reflection;
using Microsoft.VSPowerToys.PackInstaller;


namespace GUITestScenarios
{
    
    // These classes are Extensions to NUnitForms - 
    // testers for RichTextBoxes and PackInstaller's custom controls.

    public class PictureBoxTester : ControlTester
    {
        public Control.ControlCollection InnerControls
        {
            get { return ((PictureBox)Control).Controls; }
        }
        /// <summary>
        /// Provides access to Properties of the underlying Control.
        /// </summary>
        /// <remarks>
        /// Allows typed access to all of the properties of the underlying control.
        /// </remarks>
        /// <value>The underlying control.</value>
        public Control Properties
        {
            get { return Control; }
        }
        public string ControlName { get { return Control.Name; } }
        public string ControlType { get { return Control.GetType().ToString(); } }
        public PictureBoxTester(string name, Form form)
            : base(name, form)
        {
        }

        public PictureBoxTester(string name, string formName)
            : base(name, formName)
        {
        }

        public PictureBoxTester(string name)
            : base(name)
        {
        }

        public PictureBoxTester(ControlTester tester, int index)
            : base(tester, index)
        {
        }
    }

    /// <summary>
    /// A ControlTester for testing RichTextBoxes.
    /// </summary>
    /// <remarks>
    /// There is a convenience method for entering text into a text box.</remarks>
    public class RichTextBoxTester : ControlTester
    {
        /// <summary>
        /// Creates a ControlTester from the control name and the form instance.
        /// </summary>
        /// <remarks>
        /// It is best to use the overloaded Constructor that requires just the name 
        /// parameter if possible.
        /// </remarks>
        /// <param name="name">The Control name.</param>
        /// <param name="form">The Form instance.</param>
        public RichTextBoxTester(string name, Form form)
            : base(name, form)
        {
        }

        /// <summary>
        /// Creates a ControlTester from the control name and the form name.
        /// </summary>
        /// <remarks>
        /// It is best to use the overloaded Constructor that requires just the name 
        /// parameter if possible.
        /// </remarks>
        /// <param name="name">The Control name.</param>
        /// <param name="formName">The Form name..</param>
        public RichTextBoxTester(string name, string formName)
            : base(name, formName)
        {
        }

        /// <summary>
        /// Creates a ControlTester from the control name.
        /// </summary>
        /// <remarks>
        /// This is the best constructor.</remarks>
        /// <param name="name">The Control name.</param>
        public RichTextBoxTester(string name)
            : base(name)
        {
        }

        /// <summary>
        /// Creates a ControlTester from a ControlTester and an index where the
        /// original tester's name is not unique.
        /// </summary>
        /// <remarks>
        /// It is best to use the overloaded Constructor that requires just the name 
        /// parameter if possible.
        /// </remarks>
        /// <param name="tester">The ControlTester.</param>
        /// <param name="index">The index to test.</param>
        public RichTextBoxTester(ControlTester tester, int index)
            : base(tester, index)
        {
        }

        /// <summary>
        /// Allows you to find a RichTextBoxTester by index where the name is not unique.
        /// </summary>
        /// <remarks>
        /// This was added to support the ability to find controls where their name is
        /// not unique.  If all of your controls are uniquely named (I recommend this) then
        /// you will not need this.
        /// </remarks>
        /// <value>The ControlTester at the specified index.</value>
        /// <param name="index">The index of the RichTextBoxTester.</param>
        new public RichTextBoxTester this[int index]
        {
            get { return new RichTextBoxTester(this, index); }
        }

        /// <summary>
        /// Provides access to all of the Properties of the RichTextBox.
        /// </summary>
        /// <remarks>
        /// Allows typed access to all of the properties of the underlying control.
        /// </remarks>
        /// <value>The underlying control.</value>
        public RichTextBox Properties
        {
            get { return (RichTextBox)Control; }
        }

        /// <summary>
        /// This method allows you to enter text into the text box.
        /// </summary>
        /// <param name="text">The text to enter into the text box.</param>
        public void Enter(string text)
        {
            FireEvent("Enter");
            Properties.Text = text;
            FireEvent("Leave");

            EndCurrentEdit("Text");
        }
    }

    public class ToolSummaryControlTester : ControlTester
    {
        public Control.ControlCollection InnerControls
        {
            get { return ((ToolSummaryControl)Control).Controls; }
        }
        /// <summary>
        /// Provides access to Properties of the underlying Control
        /// </summary>
        /// <remarks>
        /// Allows typed access to all of the properties of the underlying control.
        /// </remarks>
        /// <value>The underlying control.</value>
        public ToolSummaryControl Properties
        {
            get { return (ToolSummaryControl)Control; }
        }
        public string ControlName { get { return Control.Name; } }
        
        public string ControlType { get { return Control.GetType().ToString(); } }
        public ToolSummaryControlTester(string name, Form form)
            : base(name, form)
        {
        }

        public ToolSummaryControlTester(string name, string formName)
            : base(name, formName)
        {
        }

        public ToolSummaryControlTester(string name)
            : base(name)
        {
        }

        public ToolSummaryControlTester(ControlTester tester, int index)
            : base(tester, index)
        {
        }
    }

    public class PackListControlTester : ControlTester
    {
        public Control.ControlCollection InnerControls
        {
            get { return ((PackListControl)Control).Controls; }
        }
        public string ControlName { get { return Control.Name; } }
        public string ControlType { get { return Control.GetType().ToString(); } }
        /// <summary>
        /// Provides access to Properties of the underlying Control
        /// </summary>
        public PackListControl Properties
        {
            get { return (PackListControl)Control; }
        }
        public PackListControlTester(string name, Form form)
            : base(name, form)
        {
        }

        public PackListControlTester(string name, string formName)
            : base(name, formName)
        {
        }

        public PackListControlTester(string name)
            : base(name)
        {
        }

        public PackListControlTester(ControlTester tester, int index)
            : base(tester, index)
        {
        }
    }

    public class PanelControlTester : ControlTester
    {
        public Control.ControlCollection InnerControls
        {
            get { return ((System.Windows.Forms.Panel)Control).Controls; }
        }
        public string ControlName { get { return Control.Name; } }
        public string ControlType { get { return Control.GetType().ToString(); } }
        /// <summary>
        /// Provides access to Properties of the underlying Control
        /// </summary>
        public Control Properties
        {
            get { return Control; }
        }
        public PanelControlTester(string name, Form form)
            : base(name, form)
        {
        }

        public PanelControlTester(string name, string formName)
            : base(name, formName)
        {
        }

        public PanelControlTester(string name)
            : base(name)
        {
        }

        public PanelControlTester(ControlTester tester, int index)
            : base(tester, index)
        {
        }
    }

    public class SortListControlTester : ControlTester
    {
        public Control.ControlCollection InnerControls
        {
            get { return ((SortListControl)Control).Controls; }
        }
        /// <summary>
        /// Provides access to all of the Properties of the underlying Control.
        /// </summary>
        /// <remarks>
        /// Allows typed access to all of the properties of the underlying control.
        /// </remarks>
        /// <value>The underlying control.</value>
        public SortListControl Properties
        {
            get { return (SortListControl)Control; }
        }
        public string ControlName { get { return Control.Name; } }
        public string ControlType { get { return Control.GetType().ToString(); } }
        public SortListControlTester(string name, Form form)
            : base(name, form)
        {
        }

        public SortListControlTester(string name, string formName)
            : base(name, formName)
        {
        }

        public SortListControlTester(string name)
            : base(name)
        {
        }

        public SortListControlTester(ControlTester tester, int index)
            : base(tester, index)
        {
        }

    }

    public class SortItemControlTester : ControlTester
    {
        public Control.ControlCollection InnerControls
        {
            get { return ((SortItemControl)Control).Controls; }
        }
        /// <summary>
        /// Provides access to all of the Properties of the underlying Control.
        /// </summary>
        /// <remarks>
        /// Allows typed access to all of the properties of the underlying control.
        /// </remarks>
        /// <value>The underlying control.</value>
        public SortItemControl Properties
        {
            get { return (SortItemControl)Control; }
        }
        public string ControlName { get { return Control.Name; } }
        public string ControlType { get { return Control.GetType().ToString(); } }
        public SortItemControlTester(string name, Form form)
            : base(name, form)
        {
        }

        public SortItemControlTester(string name, string formName)
            : base(name, formName)
        {
        }

        public SortItemControlTester(string name)
            : base(name)
        {
        }

        public SortItemControlTester(ControlTester tester, int index)
            : base(tester, index)
        {
        }

    }

    public class StatusStripTester : ControlTester
    {
        public Control.ControlCollection InnerControls
        {
            get { return ((StatusStrip)Control).Controls; }
        }
        /// <summary>
        /// Provides access to Properties of the underlying Control
        /// </summary>
        /// <remarks>
        /// Allows typed access to all of the properties of the underlying control.
        /// </remarks>
        /// <value>The underlying control.</value>
        public StatusStrip Properties
        {
            get { return (StatusStrip)Control; }
        }
        public string ControlName { get { return Control.Name; } }
        public string ControlType { get { return Control.GetType().ToString(); } }
        public StatusStripTester(string name, Form form)
            : base(name, form)
        {
        }

        public StatusStripTester(string name, string formName)
            : base(name, formName)
        {
        }

        public StatusStripTester(string name)
            : base(name)
        {
        }

        public StatusStripTester(ControlTester tester, int index)
            : base(tester, index)
        {
        }
    }

    public class TagAndFilterControlTester : ControlTester
    {
        public Control.ControlCollection InnerControls
        {
            get { return ((TagAndFilterControl)Control).Controls; }
        }
        /// <summary>
        /// Provides access to Properties of the underlying Control
        /// </summary>
        /// <remarks>
        /// Allows typed access to all of the properties of the underlying control.
        /// </remarks>
        /// <value>The underlying control.</value>
        public TagAndFilterControl Properties
        {
            get { return (TagAndFilterControl)Control; }
        }
        public string ControlName { get { return Control.Name; } }

        public string ControlType { get { return Control.GetType().ToString(); } }
        public TagAndFilterControlTester(string name, Form form)
            : base(name, form)
        {
        }

        public TagAndFilterControlTester(string name, string formName)
            : base(name, formName)
        {
        }

        public TagAndFilterControlTester(string name)
            : base(name)
        {
        }

        public TagAndFilterControlTester(ControlTester tester, int index)
            : base(tester, index)
        {
        }
    }


}
